Skip to content

Rotate Image ​

Rotate Image — LeetCode

Rotate an n x n matrix by 90 degrees clockwise, in place.

Approach ​

The trick is to know that 90 degree rotation is done by Transpose and then Reverse.

The second trick is to know how to transpose.

Remarks ​

To transpose, only swap the elements to the right of diagonal once. i = 0 to N j=i+1 to N